package com.example.ffmpegplayer.view;


import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;

public class MediaGLSurfaceView extends GLSurfaceView {
    private MediaRender mRender;

    public MediaGLSurfaceView(Context context) {
        this(context, null);
    }

    public MediaGLSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setEGLContextClientVersion(2);
        mRender = new MediaRender(context);
        setRenderer(mRender);
        setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    }

    public void setYUVData(int width, int height, byte[] y, byte[] u, byte[] v)
    {
        if (mRender != null) {
            mRender.setYUVRenderData(width, height, y, u, v);
            requestRender();
        }
    }
}
